import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * The DupEnenmy is the enemy whit medium difficulty to kill and when his die create 2 BasicEnemy.
 * 
 * @author (Arturo Aaron Rios Obregon) 
 * @version (29 june 2013)
 */
public class DupEnemy extends Enemy
{
    private int shut;
    /**
     * Constructor
     */
    public DupEnemy()
    {
        super(30);
        shut=0;
    }
    
    /**
     * Act - do whatever the DupEnemy wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {        
        super.mueve();
        super.tocaBala();
        if(getMoveE()==0)
        {
            
            if(shut%2==0)
            {
                dispara();
                shut=shut%2;
                shut+=1;
                
            }
            else 
                shut+=1;
        }
        if(getVida()==0)
            duplicate();
        super.creaItem();
        super.vidaCero();
    }
    
    /**
     * this method create 2 basic enemy when the dusEnemy is destroyed
     */    
    public void duplicate()
    {
        int x= getX(), y=getY();
        BasicEnemy ene1 = new BasicEnemy();
        BasicEnemy ene2 = new BasicEnemy();
        getWorld().addObject(ene1,x,y);
        getWorld().addObject(ene2,x,y);
    }
    
    /**
     * This method create the enemy bullets
     */
    public void dispara()
    {
        BulletEnemy bala = new BulletEnemy();
        getWorld().addObject(bala,getX(),getY()+27);
    }
}
